<!-- 换表 -->
<template>
    <div>
        <div class="changeTable">
            <div class="tableLine">
                <div class="item" v-for="(item, index) in list" v-bind:key="index">
                    <label class="itemJ">将</label>
                    <div class="tableDiv">
                        <el-input type="text" v-model="item.tableA"></el-input>
                        <span class="edit" @click="eidtTable(item)">编辑表</span>
                    </div>
                    <label class="itemH">换成</label>
                    <div class="tableDiv">
                        <el-input type="text" v-model="item.tableB"></el-input>
                        <span class="edit" @click="eidtTable(item)">编辑表</span>
                    </div>
                    <div class="close" @click="remove(item, index)">×</div>
                </div>
                <div class="addTable" @click="addTable">
                    <img src="@/assets/images/controlCenter/addTable.png" />
                    <label>添加换表</label>
                </div>
            </div>
        </div>
        <EditTable :show="show" :item="item" @close="closeTable"></EditTable>
    </div>
</template>

<script>
import EditTable from './editTable'
export default {
    name: 'addTable',
    components: {EditTable},
    data() {
        return {
            item: {},
            show: false,
            list: [
                {
                    tableA: '表a',
                    tableB: '表b'
                },
                {
                    tableA: '表a',
                    tableB: '表b'
                }
            ],
            value: '1'
        }
    },
    computed: {},
    created() {},
    methods: {
        closeTable() {
            this.show = false
        },
        eidtTable(item) {
            this.item = item
            this.show = true
        },
        remove(item, index) {
            this.list.splice(index, 1)
            console.log(item, index)
        },
        addTable() {
            var item = {
                tableA: '表a',
                tableB: '表b'
            }
            var list = this.list
            list.push(item)
            this.list = list
        }
    }
}
</script>

<style lang="scss" scoped>
.changeTable {
    padding: 10px 0;
    .tableLine {
        font-size: 14px;
        position: relative;
        margin-bottom: 20px;
        min-height: 35px;
        margin-top: 10px;
        .addTable {
            height: 22px;
            position: absolute;
            bottom: 5px;
            left: 761px;
            line-height: 22px;
            color: #4794fa;
            font-size: 14px;
            cursor: pointer;
            img {
                font-size: 12px;
                float: left;
                width: 22px;
                margin-right: 8px;
                cursor: pointer;
            }
            label {
                cursor: pointer;
            }
        }
        .item {
            height: 35px;
            line-height: 35px;
            display: flex;
            .itemJ {
                font-size: 14px;
                width: 40px;
                text-align: center;
            }
            .tableDiv {
                width: 300px;
                position: relative;
                .edit {
                    position: absolute;
                    top: 2px;
                    right: 10px;
                    color: #4794fa;
                    cursor: pointer;
                }
            }
            .itemH {
                font-size: 14px;
                width: 55px;
                text-align: center;
            }
            .close {
                font-size: 20px;
                background-color: #b3b3b3;
                height: 22px;
                width: 22px;
                border-radius: 22px;
                margin-top: 8px;
                margin-left: 30px;
                color: #fff;
                line-height: 20px;
                cursor: pointer;
                text-align: center;
            }
        }
    }
}
</style>
